home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Source.bin / InfoTipPanelBeanInfo.java < prev    next >
Text File  |  1998-08-21  |  15KB  |  394 lines

  1. package symantec.itools.awt;
  2.  
  3. import java.beans.*;
  4. import symantec.itools.beans.*;
  5. import java.util.ResourceBundle;
  6.  
  7. //  09/08/97    LAB    Moved from Additional to Panels.  Hid layout property.
  8. //    09/20/97    RKM Fixed getAdditionalBeanInfo override
  9. //  08/19/98    LAB    Moved to GroupAWTAdditions folder.
  10.  
  11. /**
  12.  * BeanInfo for InfoTipPanel.
  13.  *
  14.  */
  15. public class InfoTipPanelBeanInfo extends SimpleBeanInfo {
  16.  
  17.     /**
  18.      * Constructs a TextScrollingButtonBeanIn object.
  19.      */
  20.     public InfoTipPanelBeanInfo() {
  21.     }
  22.  
  23.     /**
  24.      * Gets an array of BeanInfo on the superclasses of this object.
  25.      * The superclasses returned are all assignable from class Object
  26.      * (see isAssignableFrom).
  27.      * @return BeanInfo on this class's superclasses
  28.      * @see java.lang.Class#isAssignableFrom
  29.      */
  30.     public BeanInfo[] getAdditionalBeanInfo() {
  31.         try {
  32.             BeanInfo[] bi = new BeanInfo[1];
  33.             bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass());
  34.             return bi;
  35.         }
  36.         catch (IntrospectionException e) { throw new Error(e.toString());}
  37.     }
  38.     
  39.     /**
  40.      * Gets the SymantecBeanDescriptor for this bean.
  41.      * @return an object of type SymantecBeanDescriptor
  42.      * @see symantec.itools.beans.SymantecBeanDescriptor
  43.      */
  44.     public BeanDescriptor getBeanDescriptor() {
  45.         ResourceBundle group = ResourceBundle.getBundle("symantec.itools.resources.GroupBundle");
  46.         String s=group.getString("GroupAWTAdditions"); 
  47.  
  48.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  49.         bd.setFolder(s);
  50.         bd.setToolbar(s);
  51.  
  52.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  53.         s=conn.getString(""); 
  54.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  55.                                                 "%name%.RIGHT_OF_COMPONENT",
  56.                                                 "RIGHT_OF_COMPONENT"));
  57.  
  58.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  59.                                                 "%name%.LEFT_OF_COMPONENT",
  60.                                                 "LEFT_OF_COMPONENT"));
  61.  
  62.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  63.                                                 "%name%.ABOVE_COMPONENT",
  64.                                                 "ABOVE_COMPONENT"));
  65.  
  66.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  67.                                                 "%name%.BELOW_COMPONENT",
  68.                                                 "BELOW_COMPONENT"));
  69.  
  70.         return (BeanDescriptor) bd;
  71.     }
  72.  
  73.     /**
  74.      * Gets an image that may be used to visually represent this bean
  75.      * (in the toolbar, on a form, etc).
  76.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  77.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  78.      * @return an image for this bean, always color even if requested monochrome
  79.      * @see BeanInfo#ICON_MONO_16x16
  80.      * @see BeanInfo#ICON_COLOR_16x16
  81.      * @see BeanInfo#ICON_MONO_32x32
  82.      * @see BeanInfo#ICON_COLOR_32x32
  83.      */
  84.     public java.awt.Image getIcon(int iconKind) {
  85.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  86.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  87.             java.awt.Image img = loadImage("InfoTipPanelC16.gif");
  88.             return img;
  89.         }
  90.  
  91.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  92.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  93.             java.awt.Image img = loadImage("InfoTipPanelC32.gif");
  94.             return img;
  95.         }
  96.  
  97.         return null;
  98.     }
  99.  
  100.     /**
  101.      * Gets an array of descriptions of the methods used for "connections" by
  102.      * Visual CafΘ's Interaction Wizard.
  103.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  104.      * @return method descriptions for this bean
  105.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  106.      */
  107.     public MethodDescriptor[] getMethodDescriptors() {
  108.         Class[] args;
  109.         ConnectionDescriptor connection;
  110.         java.util.Vector connections;
  111.         java.util.Vector md = new java.util.Vector();
  112.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  113.  
  114.         try{
  115.             args = new Class[1];
  116.             args[0] = java.lang.String.class ;
  117.             MethodDescriptor setText = new MethodDescriptor(beanClass.getMethod("setText", args));
  118.  
  119.             connections = new java.util.Vector();
  120.             connection = new ConnectionDescriptor("input", "String", "",
  121.                                     "%name%.setText(%arg%);",
  122.                                     conn.getString("setText"));
  123.             connections.addElement(connection);
  124.  
  125.             setText.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  126.             md.addElement(setText);
  127.         } catch (Exception e) { throw new Error("setText:: " + e.toString()); }
  128.  
  129.         try{
  130.             args = null;
  131.             MethodDescriptor getText = new MethodDescriptor(beanClass.getMethod("getText", args));
  132.  
  133.             connections = new java.util.Vector();
  134.             connection = new ConnectionDescriptor("output", "String", "",
  135.                                     "%name%.getText()",
  136.                                     conn.getString("getText"));
  137.             connections.addElement(connection);
  138.  
  139.             getText.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  140.             md.addElement(getText);
  141.         } catch (Exception e) { throw new Error("getText:: " + e.toString()); }
  142.  
  143.         try{
  144.             args = new Class[1];
  145.             args[0] = java.lang.Integer.TYPE ;
  146.             MethodDescriptor setTextLocation = new MethodDescriptor(beanClass.getMethod("setTextLocation", args));
  147.  
  148.             connections = new java.util.Vector();
  149.             connection = new ConnectionDescriptor("input", "int", "",
  150.                                     "%name%.setTextLocation(%arg%);",
  151.                                     conn.getString("setTextLocation"));
  152.             connections.addElement(connection);
  153.  
  154.             setTextLocation.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  155.             md.addElement(setTextLocation);
  156.         } catch (Exception e) { throw new Error("setTextLocation:: " + e.toString()); }
  157.  
  158.         try{
  159.             args = null;
  160.             MethodDescriptor getTextLocation = new MethodDescriptor(beanClass.getMethod("getTextLocation", args));
  161.  
  162.             connections = new java.util.Vector();
  163.             connection = new ConnectionDescriptor("output", "int", "",
  164.                                     "%name%.getTextLocation()",
  165.                                     conn.getString("getTextLocation"));
  166.             connections.addElement(connection);
  167.  
  168.             getTextLocation.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  169.             md.addElement(getTextLocation);
  170.         } catch (Exception e) { throw new Error("getTextLocation:: " + e.toString()); }
  171.  
  172.         try{
  173.             args = new Class[1];
  174.             args[0] = java.lang.Integer.TYPE ;
  175.             MethodDescriptor setTextDelay = new MethodDescriptor(beanClass.getMethod("setTextDelay", args));
  176.  
  177.             connections = new java.util.Vector();
  178.             connection = new ConnectionDescriptor("input", "int", "",
  179.                                     "%name%.setTextDelay(%arg%);",
  180.                                     conn.getString("setTextDelay"));
  181.             connections.addElement(connection);
  182.  
  183.             setTextDelay.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  184.             md.addElement(setTextDelay);
  185.         } catch (Exception e) { throw new Error("setTextDelay:: " + e.toString()); }
  186.  
  187.         try{
  188.             args = null;
  189.             MethodDescriptor getTextDelay = new MethodDescriptor(beanClass.getMethod("getTextDelay", args));
  190.  
  191.             connections = new java.util.Vector();
  192.             connection = new ConnectionDescriptor("output", "int", "",
  193.                                     "%name%.getTextDelay()",
  194.                                     conn.getString("getTextDelay"));
  195.             connections.addElement(connection);
  196.  
  197.             getTextDelay.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  198.             md.addElement(getTextDelay);
  199.         } catch (Exception e) { throw new Error("getTextDelay:: " + e.toString()); }
  200.  
  201.         try{
  202.             args = null;
  203.             MethodDescriptor getTextScrollsIn = new MethodDescriptor(beanClass.getMethod("getTextScrollsIn", args));
  204.  
  205.             connections = new java.util.Vector();
  206.             connection = new ConnectionDescriptor("output", "boolean", "",
  207.                                     "%name%.getTextScrollsIn()",
  208.                                     conn.getString("getTextScrollsIn"));
  209.             connections.addElement(connection);
  210.  
  211.             getTextScrollsIn.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  212.             md.addElement(getTextScrollsIn);
  213.         } catch (Exception e) { throw new Error("getTextScrollsIn:: " + e.toString()); }
  214.  
  215.         try{
  216.             args = new Class[1];
  217.             args[0] = java.lang.Boolean.TYPE ;
  218.             MethodDescriptor setTextScrollsIn = new MethodDescriptor(beanClass.getMethod("setTextScrollsIn", args));
  219.  
  220.             connections = new java.util.Vector();
  221.             connection = new ConnectionDescriptor("input", "boolean", "",
  222.                                     "%name%.setTextScrollsIn(%arg%);",
  223.                                     conn.getString("setTextScrollsIn"));
  224.             connections.addElement(connection);
  225.  
  226.             setTextScrollsIn.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  227.             md.addElement(setTextScrollsIn);
  228.         } catch (Exception e) { throw new Error("setTextScrollsIn:: " + e.toString()); }
  229.  
  230.         try{
  231.             args = null;
  232.             MethodDescriptor getHighlightText = new MethodDescriptor(beanClass.getMethod("getHighlightText", args));
  233.  
  234.             connections = new java.util.Vector();
  235.             connection = new ConnectionDescriptor("output", "boolean", "",
  236.                                     "%name%.getHighlightText()",
  237.                                     conn.getString("getHighlightText"));
  238.             connections.addElement(connection);
  239.  
  240.             getHighlightText.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  241.             md.addElement(getHighlightText);
  242.         } catch (Exception e) { throw new Error("getHighlightText:: " + e.toString()); }
  243.  
  244.         try{
  245.             args = new Class[1];
  246.             args[0] = java.lang.Boolean.TYPE ;
  247.             MethodDescriptor setHighlightText = new MethodDescriptor(beanClass.getMethod("setHighlightText", args));
  248.  
  249.             connections = new java.util.Vector();
  250.             connection = new ConnectionDescriptor("input", "boolean", "",
  251.                                     "%name%.setHighlightText(%arg%);",
  252.                                     conn.getString("setHighlightText"));
  253.             connections.addElement(connection);
  254.  
  255.             setHighlightText.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  256.             md.addElement(setHighlightText);
  257.         } catch (Exception e) { throw new Error("setHighlightText:: " + e.toString()); }
  258.  
  259.         try{
  260.             args = null;
  261.             MethodDescriptor getTextHighlightColor = new MethodDescriptor(beanClass.getMethod("getTextHighlightColor", args));
  262.  
  263.             connections = new java.util.Vector();
  264.             connection = new ConnectionDescriptor("output", "Color", "",
  265.                                     "%name%.getTextHighlightColor()",
  266.                                     conn.getString("getTextHighlightColor"));
  267.             connections.addElement(connection);
  268.  
  269.             getTextHighlightColor.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  270.             md.addElement(getTextHighlightColor);
  271.         } catch (Exception e) { throw new Error("getTextHighlightColor:: " + e.toString()); }
  272.  
  273.         try{
  274.             args = new Class[1];
  275.             args[0] = java.awt.Color.class ;
  276.             MethodDescriptor setTextHighlightColor = new MethodDescriptor(beanClass.getMethod("setTextHighlightColor", args));
  277.  
  278.             connections = new java.util.Vector();
  279.             connection = new ConnectionDescriptor("input", "Color", "",
  280.                                     "%name%.setTextHighlightColor(%arg%);",
  281.                                     conn.getString("setTextHighlightColor"));
  282.             connections.addElement(connection);
  283.  
  284.             setTextHighlightColor.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  285.             md.addElement(setTextHighlightColor);
  286.         } catch (Exception e) { throw new Error("setTextHighlightColor:: " + e.toString()); }
  287.  
  288.         try{
  289.             args = null;
  290.             MethodDescriptor getTextColor = new MethodDescriptor(beanClass.getMethod("getTextColor", args));
  291.  
  292.             connections = new java.util.Vector();
  293.             connection = new ConnectionDescriptor("output", "Color", "",
  294.                                     "%name%.getTextColor()",
  295.                                     conn.getString("getTextColor"));
  296.             connections.addElement(connection);
  297.  
  298.             getTextColor.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  299.             md.addElement(getTextColor);
  300.         } catch (Exception e) { throw new Error("getTextColor:: " + e.toString()); }
  301.  
  302.         try{
  303.             args = new Class[1];
  304.             args[0] = java.awt.Color.class ;
  305.             MethodDescriptor setTextColor = new MethodDescriptor(beanClass.getMethod("setTextColor", args));
  306.  
  307.             connections = new java.util.Vector();
  308.             connection = new ConnectionDescriptor("input", "Color", "",
  309.                                     "%name%.setTextColor(%arg%);",
  310.                                     conn.getString("setTextColor"));
  311.             connections.addElement(connection);
  312.  
  313.             setTextColor.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  314.             md.addElement(setTextColor);
  315.         } catch (Exception e) { throw new Error("setTextColor:: " + e.toString()); }
  316.  
  317.  
  318.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  319.         md.copyInto(rv);
  320.  
  321.         return rv;
  322.     }
  323.  
  324.     /**
  325.      * Returns desecriptions of this bean's properties.
  326.      */
  327.     public PropertyDescriptor[] getPropertyDescriptors() {
  328.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  329.  
  330.         try{
  331.         PropertyDescriptor defProperty = new PropertyDescriptor("text", beanClass);
  332.         defProperty.setBound(true);
  333.         defProperty.setConstrained(true);
  334.         defProperty.setDisplayName(prop.getString("text"));
  335.  
  336.         PropertyDescriptor textLocation = new PropertyDescriptor("textLocation", beanClass);
  337.         textLocation.setBound(true);
  338.         textLocation.setConstrained(true);
  339.         textLocation.setDisplayName(prop.getString("textLocation"));
  340.         textLocation.setValue("ENUMERATION", "RIGHT_OF_COMPONENT=0, LEFT_OF_COMPONENT=1, ABOVE_COMPONENT=2, BELOW_COMPONENT=3");
  341.  
  342.         PropertyDescriptor textDelay = new PropertyDescriptor("textDelay", beanClass);
  343.         textDelay.setBound(true);
  344.         textDelay.setConstrained(true);
  345.         textDelay.setDisplayName(prop.getString("textDelay"));
  346.  
  347.         PropertyDescriptor textScrollsIn = new PropertyDescriptor("textScrollsIn", beanClass);
  348.         textScrollsIn.setBound(true);
  349.         textScrollsIn.setConstrained(true);
  350.         textScrollsIn.setDisplayName(prop.getString("textScrollsIn"));
  351.  
  352.         PropertyDescriptor highlightText = new PropertyDescriptor("highlightText", beanClass);
  353.         highlightText.setBound(true);
  354.         highlightText.setConstrained(true);
  355.         highlightText.setDisplayName(prop.getString("highlightText"));
  356.  
  357.         PropertyDescriptor textHighlightColor = new PropertyDescriptor("textHighlightColor", beanClass);
  358.         textHighlightColor.setBound(true);
  359.         textHighlightColor.setConstrained(true);
  360.         textHighlightColor.setDisplayName(prop.getString("textHighlightColor"));
  361.  
  362.         PropertyDescriptor textColor = new PropertyDescriptor("textColor", beanClass);
  363.         textColor.setBound(true);
  364.         textColor.setConstrained(true);
  365.         textColor.setDisplayName(prop.getString("textColor"));
  366.  
  367.         PropertyDescriptor layout = new PropertyDescriptor("layout", beanClass);
  368.         layout.setHidden(true);
  369.  
  370.         PropertyDescriptor[] rv = {
  371.             defProperty,
  372.             textLocation,
  373.             textDelay,
  374.             textScrollsIn,
  375.             highlightText,
  376.             textHighlightColor,
  377.             textColor,
  378.             layout
  379.         };
  380.  
  381.         return rv;
  382.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  383.     }
  384.  
  385.     /**
  386.      * Returns the index of the property expected to be changed most often by the designer.
  387.      */
  388.     public int getDefaultPropertyIndex() {
  389.         return 0;    //  the index for our default property is always 0
  390.     }
  391.  
  392.     private final static Class beanClass = InfoTipPanel.class;
  393.  
  394.     }    //  end of class InfoTipPanelBeanInfo